"""
LESSON.33 Fayl va papkalar bilan ishlash
"""
# f = open('file.txt', 'r', encoding='utf-8')
# f = open('file.txt', 'r', encoding='iso-8859-1')

# text = f.read(16)
# text2 = f.read(29)
# print(f.encoding)    # utf-8
# text = f.read()    # text so'zini chop etmaydi. buyrug'i
# f.close()            # Joy tash la buyrug'i
# print(text)          # yangi qator qaz
# print(text2)

# f = open('file.txt', 'a', encoding='utf-8')
# f.write('Alo qaz\n')    # file.txt ga Alo qaz sozini qoshish
# f.close()

# lines = ['Новая строка 1', 'Eski qator']
# f = open('file.txt', 'a', encoding='utf-8')
# for i in lines:
    #    f.write(i + '\n')
    # f.writelines(lines)
# f.writelines(f'{i}\n' for i in lines)
# f.close()

# f = open('file.txt', 'r', encoding='utf-8')
# for line in f:
    #    print(line, end='')
# f.close()

lines = ['Новая строка 1', 'Alo HA ishlada']
f = open('file.txt', 'w', encoding='utf-8')
f.writelines(f'{i}\n' for i in lines)
f.close()
